package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingElderDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVO;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划")
public class NursingPlanController extends BaseController {
    @Autowired
    private NursingPlanService nursingPlanService;

    @ApiOperation("查询所有护理计划")
    @GetMapping
    public ResponseResult selectAllPlan() {
        List<NursingPlanVO> planList = nursingPlanService.selectAllPlan();
        return success(planList);
    }

    @GetMapping("/search")
    @ApiOperation("分页条件查询护理计划")
    public ResponseResult selectByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageResponse pageResponse = nursingPlanService.selectByPage(name, status, pageNum, pageSize);
        return success(pageResponse);
    }

    @ApiOperation("新增护理计划")
    @PostMapping
    public ResponseResult addNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.addNursingPlan(nursingPlanDto);
        return success();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据 id 查询护理计划")
    public ResponseResult getNursingPlan(@PathVariable Long id) {
        NursingPlanVO NursingPlanVO = nursingPlanService.getNursingPlan(id);
        return success(NursingPlanVO);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updateById(@RequestBody NursingPlanDto nursingPlanDto, @PathVariable Long id) {
        nursingPlanService.update(nursingPlanDto, id);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除护理计划")
    public ResponseResult deleteById(@PathVariable("id") Long id){
        nursingPlanService.delete(id);
        return ResponseResult.success();
    }
    /**
     * 启用禁用
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("护理计划的启用和禁用")
    public ResponseResult updateStatus(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.updateStatus(id,status);
        return ResponseResult.success();
    }
}
